package xyz.xmh.dao.recycle.impl;

import org.springframework.web.reactive.function.client.WebClient;
import xyz.xmh.api.RecycleEnum;
import xyz.xmh.dao.recycle.ReactiveRecycleDao;
import xyz.xmh.pojo.request.FileIdRequest;

/**
 * 2021/10/26 23:44 星期二<br/>
 * 响应式回收站api访问类
 *
 * @author xuMingHai
 */
public class ReactiveRecycleDaoImpl implements ReactiveRecycleDao {

    private final WebClient webClient;

    public ReactiveRecycleDaoImpl(WebClient webClient) {
        this.webClient = webClient;
    }

    @Override
    public WebClient.ResponseSpec trash(String fileId) {
        final FileIdRequest fileIdRequest = new FileIdRequest(fileId);
        final RecycleEnum trash = RecycleEnum.TRASH;
        return webClient.method(trash.getHttpMethod()).uri(trash.getApi())
                .bodyValue(fileIdRequest)
                .retrieve();
    }
}
